-- open_grid_skill
-- Created by panyl Sep/13/2016
-- 翻开格子出发技能
-- 参数列说明：
-- prop[0] : prop_id
-- prop[1] : 每翻开N个格子数
-- prop[2] : 奖励属性果ID
-- prop[3] : 奖励最大数目

return {
    apply = function(prop, baseValue)
        return baseValue;
    end,

    -- 触发
    trigger = function(who, prop, arg)
        local user = who;

        local trigger_num = prop[2];
        local skill_id = prop[3];

        local progress = PropStatM.getData1(ME.user, "open_grid_skill");
        local round = PropStatM.getData2(ME.user, "open_grid_skill");

        -- 当前回合已经触发过了
        if progress % trigger_num == 0 and CombatM.getRound() == round then
            return false;
        end

        progress = progress + 1;
        PropStatM.setData1(ME.user, "open_grid_skill", progress);
        PropStatM.setData2(ME.user, "open_grid_skill", 0);

        -- 没到触发的时候
        if progress % trigger_num ~= 0 then
            return;
        end

        PropStatM.setData2(ME.user, "open_grid_skill", CombatM.getRound());

        -- 先把触发技能缓存起来
        SkillM.skillTriggerCache(who, skill_id);

        return true;
    end,

    record = function(target, prop, path)
        return false;
    end,
};

